package com.humh.makeplanning;

import java.time.LocalDateTime;

// 任务排期
public class TaskScheduling implements Cloneable{

  private  Task task; //任务
  private LocalDateTime startTime; //任务开始时间
  private LocalDateTime  endTime; //任务结束时间


  public TaskScheduling(Task task, LocalDateTime startTime) {
    this.task = task;
    this.startTime = startTime;
  }

  /**
   * 计算任务完成时间
   */
  private void  taskCompletionTime(){
    this.endTime = startTime.plusHours(MaterialWorker.PROCESSING_TIME);

  }

  /**
   * 获取任务结束时间
   * @return
   */
  public LocalDateTime getEndTime() {
    if(endTime == null){
      this.taskCompletionTime();
    }

    return endTime;
  }

  public TaskScheduling clone(){
    return new TaskScheduling(task, startTime);
  }

  public Task getTask() {
    return task;
  }

  public LocalDateTime getStartTime() {
    return startTime;
  }
}
